package com.iflyteck.controller;

import com.iflyteck.paramDto.BlogDto;
import com.iflyteck.pojo.Article;
import com.iflyteck.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.Calendar;
import java.util.List;
import java.util.Properties;

@Controller
public class LoginController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping("/toLoginPage")
    public String toLoginPage(Model model) {
//        try {
//            Properties pro;
//            pro = new Properties().load(this.getClass().getClassLoader().getResourceAsStream("/i18n/login.properties"));
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

        model.addAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "login";
    }

    @RequestMapping("/toBlogIndex")
    public String toBlogIndex(BlogDto blogDto, Model model) {
        List<Article> articles = articleService.queryArticlePage(blogDto.getPage(), blogDto.getSize());
        model.addAttribute("articles", articles);
        return "client/index";
    }



}
